import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace PerSalaryApi {
  /** 人员工资情况信息 */
  export interface Salary {
    id: number; // 主键ID
    employeeId?: number; // 人员ID，对应 per_employee.id
    salary: number; // 工资
    partTimeIncome: number; // 兼职收入
    bonus: number; // 奖金
    otherIncome: number; // 其他收入
    totalIncome: number; // 合计收入
    year: string; // 年度
    status: number; // 是否有效（1：有效，0：无效）
  }
}

/** 查询人员工资情况分页 */
export function getSalaryPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<PerSalaryApi.Salary>>(
    '/per/salary/page',
    data,
    {
      desensitize,
      encrypt,
    },
  );
}

/** 查询人员工资情况详情 */
export function getSalary(id: number) {
  return requestClient.get<PerSalaryApi.Salary>(`/per/salary/get?id=${id}`);
}

/** 新增人员工资情况 */
export function createSalary(data: PerSalaryApi.Salary) {
  return requestClient.post('/per/salary/create', data);
}

/** 修改人员工资情况 */
export function updateSalary(data: PerSalaryApi.Salary) {
  return requestClient.put('/per/salary/update', data);
}

/** 删除人员工资情况 */
export function deleteSalary(id: number) {
  return requestClient.delete(`/per/salary/delete?id=${id}`);
}

/** 批量删除人员工资情况 */
export function deleteSalaryList(ids: number[]) {
  return requestClient.delete(`/per/salary/delete-list?ids=${ids.join(',')}`);
}

/** 导出人员工资情况 */
export function exportSalary(params: any) {
  return requestClient.download('/per/salary/export-excel', { params });
}
